<?php use_javascript('/SXShopCartPlugin/js/shopCart/showMyCart.js') ?>
<?php slot('page_title') ?>
Shopping Cart
<?php end_slot() ?>
<?php include_partial('messages') ?>
<h2>Clients Requests</h2>
<form class="centered" name="ej_ejc_frm_1" action="<?php echo url_for('CheckOut') ?>" method="post" id="productsForm">
    <table  class="table table-bordered table-striped adminGrid" summary="Meeting Results">
        <thead>
            <tr>
                <th>No.</th>
                <th width="40%">Product</th>
                <th width="15%">Quantity</th>
                <th>Price </th>
                <th>Total </th>
                <th>Remove</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $totalPrice    = 0;
            $totalQuantity = 0;
            ?>
            <?php foreach ($products as $k => $product): ?>
                <tr class="inUsed">
                    <td><?php echo $k + 1 ?></td>
                    <td><?php echo $product ?></td>

                    <td><input class="quantity" type="text" value="<?php echo $items[$product->getId()] ?>" maxlength="10" name="quantity[<?php echo $product->getId() ?>]" style="width:70%;"></td>
                    <td>$ <?php echo $product->getPrice() ?></td>
                    <td>
                        $<span id="showPrice"><?php echo $product->getPrice() * $items[$product->getId()] ?></span>
                        <input type="hidden" class="price" value="<?php echo $product->getPrice() ?>" />
                    </td>
                    <td>
                        <ul class="actions">
                            <li>
                                <a href="<?php echo url_for('RemoveFromShopCart', array('pid' => $product->getId())) ?>" class="removeFromCart delete">
                                </a>
                            </li>
                    </td>
                </tr>
                <?php
                $totalPrice+=$product->getPrice() * $items[$product->getId()];
                $totalQuantity+=$items[$product->getId()];
                ?>
            <?php endforeach; ?>
            <tr>
                <td colspan="2">Total:</td>
                <td colspan="1"><span id="totalQuantity"><?php echo $totalQuantity ?></span></td>
                <td></td>
                <td colspan="2">$<span id="totalPrice"><?php echo $totalPrice ?></span></td>
            </tr>
        </tbody>
    </table>
    <div class="cartControl">
        <a class="submit button" onclick="$('#productsForm').submit()">Buy Products</a>
    </div>
</form>
